home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kconfigdata.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.6 KB  |  147 lines

  1. /*
  2.    This file is part of the KDE libraries
  3.    Copyright (c) 1999-2000 Preston Brown <pbrown@kde.org>
  4.    Copyright (C) 1996-2000 Matthias Kalle Dalheimer <kalle@kde.org>
  5.  
  6.    This library is free software; you can redistribute it and/or
  7.    modify it under the terms of the GNU Library General Public
  8.    License as published by the Free Software Foundation; either
  9.    version 2 of the License, or (at your option) any later version.
  10.  
  11.    This library is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.    Library General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU Library General Public License
  17.    along with this library; see the file COPYING.LIB.  If not, write to
  18.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19.    Boston, MA 02110-1301, USA.
  20. */
  21.  
  22. #ifndef _KCONFIGDATA_H
  23. #define _KCONFIGDATA_H
  24.  
  25. #include <qmap.h> // generic red-black tree class
  26. #include "kdelibs_export.h"
  27.  
  28. /**
  29.  * map/dict/list config node entry.
  30.  * @internal
  31.  */
  32. struct KDECORE_EXPORT KEntry
  33. {
  34.   KEntry()
  35.     : mValue(0), bDirty(false), bNLS(false), 
  36.       bGlobal(false), bImmutable(false), bDeleted(false), bExpand(false) {}
  37.   QCString mValue;
  38.   /**
  39.    * Must the entry be written back to disk?
  40.    */
  41.   bool    bDirty :1;
  42.   /**
  43.    * Entry should be written with locale tag
  44.    */ 
  45.   bool    bNLS   :1;
  46.   /**
  47.    * Entry should be written to the global config file
  48.    */ 
  49.   bool    bGlobal:1;
  50.   /**
  51.    * Entry can not be modified.
  52.    */ 
  53.   bool    bImmutable:1;
  54.   /**
  55.    * Entry has been deleted.
  56.    */
  57.   bool    bDeleted:1;
  58.   /**
  59.    * Whether to apply dollar expansion or not.
  60.    */ 
  61.   bool    bExpand:1;
  62. };
  63.  
  64. /**
  65.  * key structure holding both the actual key and the the group
  66.  * to which it belongs.
  67.  * @internal
  68.  */
  69. struct KDECORE_EXPORT KEntryKey
  70. {
  71.   KEntryKey(const QCString& _group = 0,
  72.         const QCString& _key = 0)
  73.       : mGroup(_group), mKey(_key), bLocal(false), bDefault(false),
  74.         c_key(_key.data()) {}
  75.   /**
  76.    * The "group" to which this EntryKey belongs
  77.    */ 
  78.   QCString mGroup;
  79.   /**
  80.    * The _actual_ key of the entry in question
  81.    */ 
  82.   QCString mKey;
  83.   /**
  84.    * Entry is localised or not
  85.    */ 
  86.   bool    bLocal  :1;
  87.   /**
  88.    * Entry indicates if this is a default value.
  89.    */ 
  90.   bool    bDefault:1;
  91.  
  92.   const char *c_key;
  93. };
  94.  
  95. /**
  96.  * compares two KEntryKeys (needed for QMap).
  97.  * @internal
  98.  */
  99. inline bool operator <(const KEntryKey &k1, const KEntryKey &k2)
  100. {
  101.    //saves one strcmp on each call
  102.    int result=qstrcmp(k1.mGroup.data(),k2.mGroup.data());
  103.    if (result!=0)
  104.       return (result<0);     
  105.  
  106.   if (!k1.c_key && k2.c_key)
  107.     return true;
  108.  
  109.   result = 0;
  110.   if (k1.c_key && k2.c_key)
  111.      result = strcmp(k1.c_key, k2.c_key);
  112.   if (result != 0)
  113.      return result < 0;
  114.   if (!k1.bLocal && k2.bLocal)
  115.     return true;
  116.   if (k1.bLocal && !k2.bLocal)
  117.     return false;
  118.   return (!k1.bDefault && k2.bDefault);
  119. }
  120.  
  121. /**
  122.  * \relates KEntry
  123.  * type specifying a map of entries (key,value pairs).
  124.  * The keys are actually a key in a particular config file group together
  125.  * with the group name.
  126.  * @internal
  127.  */
  128. typedef QMap<KEntryKey, KEntry> KEntryMap;
  129.  
  130. /**
  131.  * \relates KEntry
  132.  * type for iterating over keys in a KEntryMap in sorted order.
  133.  * @internal
  134.  */
  135. typedef QMap<KEntryKey, KEntry>::Iterator KEntryMapIterator;
  136.  
  137. /**
  138.  * \relates KEntry
  139.  * type for iterating over keys in a KEntryMap in sorted order.
  140.  * It is const, thus you cannot change the entries in the iterator,
  141.  * only examine them.
  142.  * @internal
  143.  */
  144. typedef QMap<KEntryKey, KEntry>::ConstIterator KEntryMapConstIterator;
  145.  
  146. #endif
  147.